from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, 
                            QHBoxLayout, QPushButton, QLineEdit, QListWidget, 
                            QLabel, QMessageBox,QDialog)
from PyQt6 import QtCore, QtGui, QtWidgets
from  sls_mirrors import sls_UGVmirrorsUpdate,sls_agent
from sls_serverselect import Ui_statusDialog


class ServerSelectDialog(QDialog):
    def __init__(self):
        super().__init__()
        self.ui = Ui_statusDialog()
        self.ui.setupUi(self)
        self.setWindowTitle("江苏大学空地协同上位机平台")
        self.setFixedSize(self.width(), self.height())
        self.mode = True                                         # 默认是本地模式
        self.selected_coordinates = (119.515293, 32.199403)      # 默认经纬度
        
        # 绑定登陆按钮
        self.ui.pushButton_ok.clicked.connect(self.confirm_selection)
        
        self.ui.localButton.setChecked(True)
        
        # 下拉列表选择地点,需按照顺序添加
        self.ui.placeBox_switch.addItem("江苏大学")
        self.ui.placeBox_switch.addItem("雷公岛")
        self.locations = [
            (119.508871, 32.197527),                            #"江苏大学"
            (119.734099, 32.295388)                             #"雷公岛"
        ]

    def confirm_selection(self):
        if self.ui.localButton.isChecked():
            self.mode = True
        elif self.ui.remoteButton.isChecked():
            self.mode = False
            
        """根据Index获得locations"""
        self.selected_coordinates = self.locations[self.ui.placeBox_switch.currentIndex()]

        """确定选择并关闭"""
        self.accept()  # 返回 QDialog.DialogCode.Accepted